/*
 * File:   r_main.c
 * Created on April 8, 2013, 10:12 AM
 */

#include <p24FJ64GA002.h>
#include "states.h"
#include "config.h"
#include "rf_module.h"

/* ************************************************************************** */

int main(void)
{
    SetCurrentPrimaryState(PRIMARY_STATE_INIT);
    while (1) {
        switch (g_CurrentPrimaryState) {
            case PRIMARY_STATE_INIT:
                PrimaryStateInit();
                break;
            case PRIMARY_STATE_SEARCH_IR:
                PrimaryStateSearchIR();
                break;
            case PRIMARY_STATE_FOLLOW_TAPE:
                PrimaryStateFollowTape();
                break;
            case PRIMARY_STATE_LEAVE_TAPE:
                PrimaryStateLeaveTape();
                break;
            case PRIMARY_STATE_TURN_180:
                PrimaryStateTurn180();
                break;
            case PRIMARY_STATE_MIDDLE_CIRCLE:
                PrimaryStateMiddleCircle();
                break;
            case PRIMARY_STATE_DO_NOTHING:
                break;
            default:
                SetCurrentPrimaryState(PRIMARY_STATE_INIT);
                break;
        }
        RFModuleProcess();
    }

    return 0;
}
